#include "ConfigLoad.hpp"
#include <stdexcept>
#include <filesystem>
#include <vector>

ConfigLoad::ConfigLoad()
{
  if(!std::filesystem::exists("/tmp/HBTY_server_ipc.yaml"))
    throw std::runtime_error("配置文件不存在");
  YAML::Node config=YAML::LoadFile("/tmp/HBTY_server_ipc.yaml");
  if(!config["shm"].IsSequence())
    throw std::runtime_error("配置文件项目shm不存在");
  CameraIDList.reserve(config["shm"].size());
  for(std::size_t i=0;i<config["shm"].size();i++)
    CameraIDList.push_back(config["shm"][i].as<std::string>());
  shmSize=config["shm_size"].as<long>();
}

std::vector<std::string> ConfigLoad::GetCameraIDList()
{
  return CameraIDList;
}

long ConfigLoad::GetShmSize()
{
  return shmSize;
}
